﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Web.Script.Serialization;

public partial class user_UpLoad :Wozuji.Logic.PageLogin
{
    protected void Page_Load(object sender, EventArgs e)
    {
        savefile();
    }

    private void savefile()
    {
        Response.ClearHeaders();
        Response.Clear();
        Response.Expires = 0;
        Response.ClearContent();
        Data d = new Data();

        try
        {
            if (Request.Files.Count > 0)
            {
                var file = Request.Files[0];
                string filename = file.FileName;
                string path = Server.MapPath("~\\img\\editUpImages\\" + filename);
                d.msg = "/images/editUpImages/" + filename;
                file.SaveAs(path);
            }
        }
        catch (Exception e)
        {
            d.err = e.Message;
        }

        JavaScriptSerializer serializer = new JavaScriptSerializer();
        Response.Write(serializer.Serialize(d));
        Response.Flush();
        Response.End();
    }
}
public class Data
{
    private string _err;
    private string _msg;
    public string err
    {
        get
        {
            if (_err == null)
                return string.Empty;
            return _err;
        }
        set
        {
            _err = value;
        }
    }
    public string msg
    {
        get
        {
            if (_msg == null)
                return string.Empty;
            return _msg;
        }
        set
        {
            _msg = value;
        }
    }
}
